from math import sqrt

def isprime(candidate, primes):
    root = sqrt(candidate)
    for p in primes:
        if p > root + 1:
            return True
        if candidate % p == 0:
            return False
        
    return True

def solution1():
    primes = [2,3,5,7,11,13]
    
    next = 17
    step = 2
    nr = 10001
    
    while len(primes) < nr:
        if isprime(next, primes):
            primes.append(next)
    
        next += step
            
    print primes[nr - 1]

from timeit import Timer
print Timer('solution1()', 'from __main__ import solution1').timeit(1)  

